package com.zmj.sy.mom.srv.aps.config;

import cn.hutool.core.date.DatePattern;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.context.annotation.Configuration;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

@Configuration
public class ObjectMapperConfig {

    public ObjectMapperConfig(ObjectMapper objectMapper){
        objectMapper.findAndRegisterModules();
        objectMapper.configOverride(LocalDate.class).setFormat(JsonFormat.Value.forPattern(DatePattern.NORM_DATE_PATTERN));
        objectMapper.configOverride(LocalDateTime.class).setFormat(JsonFormat.Value.forPattern(DatePattern.NORM_DATETIME_PATTERN));
        objectMapper.configOverride(LocalTime.class).setFormat(JsonFormat.Value.forPattern(DatePattern.NORM_TIME_PATTERN));
    }
}
